﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SDSystem.Models;
using PagedList;

namespace SDSystem.Controllers
{
    public class WebsiteController : Controller
    {
        //
        // GET: /Website/
        ForumEntities db = new ForumEntities();
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult NewsPage(int? page)
        {
            int pageSize = 3;
            int pageNumber = (page ?? 1);
            return View(db.News.OrderByDescending(e => e.NewsId).ToPagedList(pageNumber, pageSize));

        }


        //Restaurant
        public ActionResult RestaurantPage(int? page)
        {
            int pageSize = 3;
            int pageNumber = (page ?? 1);
            return View(db.Restaurants.OrderByDescending(e => e.RestaurantId).ToPagedList(pageNumber, pageSize));
        }

        public ActionResult RestaurantDetail(int id)
        {
            Restaurant rs = db.Restaurants.SingleOrDefault(e => e.RestaurantId == id);
            ViewBag.MapsLocation = rs.Street + "," + rs.City + ",Việt Nam";
            return View(rs);
        }

        //Dishes
        public ActionResult DishesPage(int? page)
        {
            int pageSize = 3;
            int pageNumber = (page ?? 1);
            return View(db.Dishes.OrderByDescending(e=>e.DishesId).ToPagedList(pageNumber, pageSize));
        }

        public ActionResult DishesDetail(int id)
        {
            Dish dh = db.Dishes.SingleOrDefault(e => e.DishesId == id);
            return View(dh);
        }

        //Forum
        public ActionResult ForumPage()
        {
            return View();
        }

        //Gioi thieu
        public ActionResult About()
        {
            return View();
        }

    }
}
